//
//  QLPublishSeekHelpCell.m
//  神约
//
//  Created by qlwl on 17/2/15.
//  Copyright © 2017年 qlwl. All rights reserved.
//

#import "QLPublishSeekHelpCell.h"

@implementation QLPublishSeekHelpCell9
- (void)textViewDidChange:(UITextView *)textView
{
    if (self.contentChanged) {
        self.contentChanged(textView.text);
    }
}
@end
@implementation QLPublishSeekHelpCell8

@end
@implementation QLPublishSeekHelpCell7
- (IBAction)unLimitedBtnClick:(id)sender {
    NSArray * btns = @[self.unLimitedBtn,self.leftLimitBtn,self.rightLimitBtn];
    [self selectBtn:sender inBtns:btns];
    if (self.serviceModeChanged) {
        self.serviceModeChanged(2);
    }
}
- (IBAction)leftLimitedBtnClick:(id)sender {
    NSArray * btns = @[self.unLimitedBtn,self.leftLimitBtn,self.rightLimitBtn];
    [self selectBtn:sender inBtns:btns];
    if (self.serviceModeChanged) {
        self.serviceModeChanged(1);
    }
}
- (IBAction)rightLimitedBtnClick:(id)sender {
    NSArray * btns = @[self.unLimitedBtn,self.leftLimitBtn,self.rightLimitBtn];
    [self selectBtn:sender inBtns:btns];
    if (self.serviceModeChanged) {
        self.serviceModeChanged(0);
    }
}
- (void)selectBtn:(UIButton *)btn inBtns:(NSArray *)btns
{
    for (UIButton * btn in btns) {
        btn.selected = NO;
        btn.userInteractionEnabled = YES;
    }
    btn.selected = YES;
    btn.userInteractionEnabled = NO;
}

- (void)setServiceMode:(int)serviceMode
{
    NSArray * btns = @[self.unLimitedBtn,self.leftLimitBtn,self.rightLimitBtn];
    _serviceMode = serviceMode;
    if (_serviceMode == 0) {
        [self selectBtn:self.rightLimitBtn inBtns:btns];
    }else if (_serviceMode == 1){
        [self selectBtn:self.leftLimitBtn inBtns:btns];
    }else if (_serviceMode == 2){
        [self selectBtn:self.unLimitedBtn inBtns:btns];
    }else{
        [self selectBtn:nil inBtns:btns];
    }
}
@end
@implementation QLPublishSeekHelpCell6
- (IBAction)unLimitedBtnClick:(id)sender {
    NSArray * btns = @[self.unLimitedBtn,self.leftLimitBtn,self.rightLimitBtn];
    [self selectBtn:sender inBtns:btns];
    if (self.sexChanged) {
        self.sexChanged(2);
    }
}
- (IBAction)leftLimitedBtnClick:(id)sender {
    NSArray * btns = @[self.unLimitedBtn,self.leftLimitBtn,self.rightLimitBtn];
    [self selectBtn:sender inBtns:btns];
    if (self.sexChanged) {
        self.sexChanged(1);
    }
}
- (IBAction)rightLimitedBtnClick:(id)sender {
    NSArray * btns = @[self.unLimitedBtn,self.leftLimitBtn,self.rightLimitBtn];
    [self selectBtn:sender inBtns:btns];
    if (self.sexChanged) {
        self.sexChanged(0);
    }
}
- (void)selectBtn:(UIButton *)btn inBtns:(NSArray *)btns
{
    for (UIButton * btn in btns) {
        btn.selected = NO;
        btn.userInteractionEnabled = YES;
    }
    btn.selected = YES;
    btn.userInteractionEnabled = NO;
}
- (void)setSexType:(int)sexType
{
    _sexType = sexType;
    NSArray * btns = @[self.unLimitedBtn,self.leftLimitBtn,self.rightLimitBtn];
    if (_sexType == 0) {
        [self selectBtn:self.rightLimitBtn inBtns:btns];
    }else if (_sexType == 1){
        [self selectBtn:self.leftLimitBtn inBtns:btns];
    }else if (_sexType == 2){
        [self selectBtn:self.unLimitedBtn inBtns:btns];
    }else{
         [self selectBtn:nil inBtns:btns];
    }
}


@end
@implementation QLPublishSeekHelpCell5
- (IBAction)selectBtnClick:(id)sender {
    UIButton * btn = sender;
    btn.selected = !btn.selected;
    if (self.selectClick) {
        self.selectClick(btn.selected);
    }
}

@end
@implementation QLPublishSeekHelpCell4
- (IBAction)byOrderBtnClick:(id)sender {
    NSArray * btns = @[self.byOrderBtn,self.byTimeBtn];
    UIButton * currentBtn = sender;
    for (UIButton * btn in btns) {
        btn.selected = NO;
        btn.userInteractionEnabled = YES;
    }
    currentBtn.selected = YES;
    currentBtn.userInteractionEnabled = NO;
    if (self.byTypeChanged) {
        self.byTypeChanged(1);
    }
}
- (IBAction)byTimeBtnClick:(id)sender {
    NSArray * btns = @[self.byOrderBtn,self.byTimeBtn];
    UIButton * currentBtn = sender;
    for (UIButton * btn in btns) {
        btn.selected = NO;
        btn.userInteractionEnabled = YES;
    }
    currentBtn.selected = YES;
    currentBtn.userInteractionEnabled = NO;
    if (self.byTypeChanged) {
        self.byTypeChanged(2);
    }
}
- (void) setUnitPrice:(int)unitPrice
{
    _unitPrice = unitPrice;
    if (_unitPrice == 1) {
        self.byOrderBtn.selected = YES;
        self.byOrderBtn.userInteractionEnabled = NO;
        self.byTimeBtn.selected = NO;
        self.byTimeBtn.userInteractionEnabled = YES;
    }else if (_unitPrice == 2){
        self.byOrderBtn.selected = NO;
        self.byOrderBtn.userInteractionEnabled = YES;
        self.byTimeBtn.selected = YES;
        self.byTimeBtn.userInteractionEnabled = NO;
    }else{
        self.byOrderBtn.selected = NO;
        self.byOrderBtn.userInteractionEnabled = YES;
        self.byTimeBtn.selected = NO;
        self.byTimeBtn.userInteractionEnabled = YES;
    }
}

@end
@implementation QLPublishSeekHelpCell3
- (IBAction)textFieldChanged:(id)sender {
    UITextField * field = sender;
    if (self.priceChanged) {
        self.priceChanged(field.text);
    }
}

@end
@implementation QLPublishSeekHelpCell2
- (IBAction)freePayBtnClick:(id)sender {
    NSArray * btns = @[self.freePayBtn,self.notFreePayBtn];
    UIButton * currentBtn = sender;
    for (UIButton * btn in btns) {
        btn.selected = NO;
        btn.userInteractionEnabled = YES;
    }
    currentBtn.selected = YES;
    currentBtn.userInteractionEnabled = NO;
    if (self.isPayClick) {
        self.isPayClick(NO);
    }
}
- (IBAction)notFreePayBtnClick:(id)sender {
    NSArray * btns = @[self.freePayBtn,self.notFreePayBtn];
    UIButton * currentBtn = sender;
    for (UIButton * btn in btns) {
        btn.selected = NO;
        btn.userInteractionEnabled = YES;
    }
    currentBtn.selected = YES;
    currentBtn.userInteractionEnabled = NO;
    if (self.isPayClick) {
        self.isPayClick(YES);
    }
}
- (void)setIsPay:(BOOL)isPay
{
    _isPay = isPay;
    self.freePayBtn.selected = !_isPay;
    self.freePayBtn.userInteractionEnabled = _isPay;
    self.notFreePayBtn.selected = _isPay;
    self.notFreePayBtn.userInteractionEnabled = !_isPay;
}


@end

@implementation QLPublishSeekHelpCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
